import { createSlice } from "@reduxjs/toolkit";

export const CitySlice = createSlice({
  name: "CitySlice",
  initialState: {
    start: "北京",
    end: "上海",
  },
  reducers: {
    setCity(state, { payload: { type, city } }) {
      console.log(type, city);
      state[type] = city;
    },
    exChange(state) {
      const temp = state.start;
      state.start = state.end;
      state.end = temp;
    },
  },
});

export const { setCity, exChange } = CitySlice.actions;

export default CitySlice.reducer;
